package cn.navclub.xt.server.verticle

import cn.navclub.xt.server.AbstractEBVerticle
import cn.navclub.xt.server.api.CommonResult
import cn.navclub.xt.server.api.RestResponse
import cn.navclub.xt.server.config.PASSWORD
import cn.navclub.xt.server.config.USERNAME
import cn.navclub.xt.server.enums.APPAction
import cn.navclub.xt.server.service.UserService
import cn.navclub.xt.server.service.impl.UserServiceImpl
import io.vertx.core.json.JsonObject

/**
 *
 * 用户相关操作接口
 *
 */
class SSOVerticel : AbstractEBVerticle() {
    private lateinit var userService:UserService

    override suspend fun start() {
        super.start()
        this.userService = UserServiceImpl()
    }

    override suspend fun restReq(action: APPAction, data: JsonObject): CommonResult<*> {
        if (action == APPAction.USER_LOGIN) {
            return userService.login(data.getString(USERNAME), data.getString(PASSWORD))
        }
        return RestResponse.fail<Void>("404")
    }
}